home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / V3DDemo / Source / Sources / V3DDocModel.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  1.4 KB  |  78 lines

  1. /*    ==============
  2.  *    V3DDocModel.cc
  3.  *    ==============
  4.  */
  5.  
  6. #include <ctype.h>
  7. #include <stdio.h>
  8.  
  9. #include "SiesString.hh"
  10.  
  11. #include "PedWindow.hh"
  12. #include "PedChoreGeneric.hh"
  13. #include "Ped1AppProcess.hh"
  14. #include "PedApplication.hh"
  15. #include "PedFSRef.hh"
  16. #include "PedDataSourceFile.hh"
  17. #include "PedStreamInputBuffered.hh"
  18. #include "PedDispenserString.hh"
  19.  
  20. #include "C3DPort.hh"
  21. #include "C3DModel.hh"
  22.  
  23. #include "V3DDocModel.hh"
  24. #include "V3DPanePort.hh"
  25.  
  26.  
  27. V3DDocModel::V3DDocModel()
  28. : /*PedDocument(NULL),*/ mModel(NULL), mPane(NULL), mAnimateChore(NULL)
  29. {
  30.     mModel = new C3DModel;
  31. }
  32.  
  33. V3DDocModel::~V3DDocModel()
  34. {
  35.     if (mModel) delete mModel;
  36. }
  37.  
  38. C3DModel *
  39. V3DDocModel::Model()
  40. {
  41.     return mModel;
  42. }
  43.  
  44. void
  45. V3DDocModel::Load()
  46. {
  47.     if (!mModel || !mFile) return;
  48.     PedDataSourceFile *source = new PedDataSourceFile(*mFile);
  49.     source->autorelease();
  50.     PedStreamInputBuffered *stream = new PedStreamInputBuffered(*source);
  51.     stream->autorelease();
  52.     PedDispenserString *dispenser = new PedDispenserString(*stream);
  53.     dispenser->autorelease();
  54.     
  55.     SiesString string;
  56.     while (dispenser->GetString(string)) {
  57.         long len = string.Length();
  58.         if (len == 0) continue;
  59.         char *str = new char [len + 1];
  60.         string.GetCStr(str, len);
  61.         if (isalpha(str[0])) {
  62.             str++;
  63.         }
  64.         double x, y, z;
  65.         long scanned = sscanf(str, "%lf %lf %lf", &x, &y, &z);
  66.         delete [] str;
  67.         if (scanned == 3) {
  68.             mModel->AddDot(x, y, z);
  69.         }
  70.     }
  71. }
  72.  
  73. void
  74. V3DDocModel::Store()
  75. {
  76.  
  77. }
  78.